<!DOCTYPE html>
<html>
  <head><meta name="generator" content="Hexo 3.8.0">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="fengzhaoyang&#39;s blog">
  <meta name="keyword" content="hexo-theme, vuejs">
  
  <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
    Linux system 命令 | fzy-blog
    
  </title>
  <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  <link rel="stylesheet" href="/css/style.css">
  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
  
  <script src="/js/qrious.js"></script>
  
  
  
  
    <!-- MathJax support START -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <!-- MathJax support END -->
  


</head>
<div class="wechat-share">
  <img src="/css/images/logo.png">
</div>
  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>fzy-blog</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">Home</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">Tags</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">Archives</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/project/" class="item-link">Projects</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">About</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">Home</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">Tags</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">Archives</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/project/" class="menu-link">Projects</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">About</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>

    <div id="article-banner">
  <h2>Linux system 命令</h2>
  <p class="post-date">2019-05-24</p>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><h1 id="Linux-system-命令"><a href="#Linux-system-命令" class="headerlink" title="Linux system 命令"></a>Linux system 命令</h1><p>常用命令</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br></pre></td><td class="code"><pre><span class="line">一、文件操作</span><br><span class="line">cd ~ 进入主目录 cd .. 返回上一级目录 cd .... 返回上两级目录 cd - 返回上次所在的目录</span><br><span class="line">ls 查看当前目录下的文件 ls -l a* 列出当前目录以a开头的文件 ls -a 查看所有文件 包括隐藏文件</span><br><span class="line">ll 查看文件详细信息</span><br><span class="line">mkdir 文件名 新建文件夹</span><br><span class="line">rmdir 文件名 是删除文件夹目录 mkdir dir1 dir2 同时创建两个目录 mkdir -p tmpdir1dir2 创建一个目录树</span><br><span class="line">cp file1 file2 复制文件到 某个文件目录 cp -rf /tomcat/*  /tomcat2/  复制文件夹  cp dir . 复制一个目录下的所有文件到当前工作目录</span><br><span class="line">cp -a file1 file2 在保留原文件属性的前提下复制文件</span><br><span class="line">mv 移动指定文件到指定位置 mv dir1 new_dir 重命名移动 一个目录</span><br><span class="line">rm a.log 删除普通文件</span><br><span class="line">rm -rf *.*  删除这个目录下所有的文件</span><br><span class="line">rm -rf *关键字*  删除和关键字有关的所有文件 -r 就是向下递归，不管有多少级目录，一并删除 -f 就是直接强行删除，不作任何提示的意思</span><br><span class="line">tail -f 文件名 实时查看被添加到一个文件中的内容</span><br><span class="line">cat file1 从第一个字节开始正向查看文件的内容</span><br><span class="line">tac file1 从最后一行开始反向查看一个文件的内容</span><br><span class="line">more file1 查看一个长文件的内容</span><br><span class="line">less file1 类似于 'more' 命令，但是它允许在文件中和正向操作一样的反向操作</span><br><span class="line">head -2 file1 查看一个文件的前两行</span><br><span class="line">tail -2 file1 查看一个文件的最后两行</span><br><span class="line">tail -f varlogmessages 实时查看被添加到一个文件中的内容</span><br><span class="line">pwd 显示工作路径</span><br><span class="line">rz -y 上传文件  sz 下载文件</span><br><span class="line">zip  把/home目录下面的mydata目录压缩为mydata.zip</span><br><span class="line">zip -r mydata.zip mydata #压缩mydata目录</span><br><span class="line">zip -r abc123.zip abc 123.txt  把/home目录下面的abc文件夹和123.txt压缩成为abc123.zip</span><br><span class="line">unzip mydata.zip -d mydatabak  把/home目录下面的mydata.zip解压到mydatabak目录里面</span><br><span class="line">sudo unzip -oq iss.war -d ../tomcat7/webapps/iss</span><br><span class="line">unzip wwwroot.zip  把/home目录下面的wwwroot.zip直接解压到/home目录里面</span><br><span class="line">unzip -v wwwroot.zip  查看把/home目录下面的wwwroot.zip里面的内容</span><br><span class="line">unzip -j wwwroot.zip   把/home目录下面wwwroot.zip里面的所有文件解压到第一级目录</span><br><span class="line">tar -czf test.tar.gz /test1 /test2 压缩文件</span><br><span class="line">tar -xvzf test.tar.gz 解压文件</span><br><span class="line">jar -xvf project.war /project_a</span><br><span class="line">jar -xvf project.war</span><br><span class="line">tree 显示文件和目录由根目录开始的树形结构</span><br><span class="line">lstree 显示文件和目录由根目录开始的树形结构</span><br><span class="line">ln -s file1 lnk1 创建一个指向文件或目录的软链接</span><br><span class="line">ln file1 lnk1 创建一个指向文件或目录的物理链接</span><br><span class="line">touch file.txt 创建一个新文件 -t 0712250000 file1 修改一个文件或目录的时间戳 - (YYMMDDhhmm)</span><br><span class="line">vim  file1 编辑文件</span><br><span class="line">vi  file1  编辑文件</span><br><span class="line">sed -i 's/user/userName/g' 123.txt sed命令可以批量替换多个文件中的字符串</span><br><span class="line">perl -pie "s/wq/192.168.1.53/g" 123.txt   把123.txt文件中的所有wq都替换为192.168.1.153</span><br><span class="line"><span class="meta">&gt;</span> filename  清空文件</span><br><span class="line"></span><br><span class="line">二、查找文件：</span><br><span class="line">ls | grep app*  搜索当前目录下指定文件</span><br><span class="line">whereis nginx</span><br><span class="line">whereis java</span><br><span class="line">从根据目录开始查找</span><br><span class="line">find / -name tomcat</span><br><span class="line">find / -name 123 搜索根和子目录 名字为 123的文件</span><br><span class="line">从根目录开始查找所有扩展名为.log的文本文件，并找出包含”ERROR”的行</span><br><span class="line">find / -type f -name "*.log" | xargs grep "ERROR"</span><br><span class="line">系统查找到httpd.conf文件后即时在屏幕上显示httpd.conf文件信息。</span><br><span class="line">find / -name "httpd.conf" -ls</span><br><span class="line">在根目录下查找某个文件</span><br><span class="line">find . -name "test"</span><br><span class="line">在某个目录下查找包含某个字符串的文件</span><br><span class="line">grep -r "zh_CN" ./</span><br><span class="line">grep -niR 'exception'  filename</span><br><span class="line">注：n，显示行号　R，查找所有文件包含子目录　i,忽略大小写 最后的“xxx”表示想要查找的文件名</span><br><span class="line">head -n 10 example.txt 查看文件前10行</span><br><span class="line">tail -n 10 example.txt</span><br><span class="line"></span><br><span class="line">三、进程和端口</span><br><span class="line">netstat -apn 查看所有进程和端口使用情况，其中最后一栏是PID/Program name</span><br><span class="line">netstat –apn | grep 8080 查看8080端口使用情况</span><br><span class="line">ip addr 查看IP</span><br><span class="line">ps -ef 查看正在活动的进程 ps -ef | grep ecp 查看进程中有ecp的所有进程</span><br><span class="line">kill -9 xxxxxx 关闭某个进程</span><br><span class="line"></span><br><span class="line">四、网络</span><br><span class="line">ifconfig eth0 显示一个以太网卡的配置</span><br><span class="line">ifup eth0 启用一个 'eth0' 网络设备</span><br><span class="line">ifdown eth0 禁用一个 'eth0' 网络设备</span><br><span class="line">ifconfig eth0 192.168.1.1 netmask 255.255.255.0 控制IP地址</span><br><span class="line">mount -t cifs //ip地址/共享文件夹名 /mnt -o username=FZY,password=feng</span><br><span class="line">scp full.tar.gz root@192.168.191.128:/opt/soft   把当前系统文件复制到远程linux主机</span><br><span class="line">scp root@192.168.191.128:/opt/soft/test.txt /opt/soft/  把远程linux主机文件复制到当前系统</span><br><span class="line">clear：如果你觉得你的屏幕上有太多的东西，看起来很讨厌，可以使用clear命令清空</span><br><span class="line">echo command 打印出你的输入</span><br><span class="line">ctrl + c 中止当前执行的脚本  回到命令输入模式</span><br><span class="line"></span><br><span class="line">五、磁盘</span><br><span class="line">df -hl 查看磁盘剩余空间</span><br><span class="line">df -h 查看每个根路径的分区大小</span><br><span class="line">du -sh [目录名] 返回该目录的大小</span><br><span class="line">du -sm [文件夹] 返回该文件夹总M数</span><br><span class="line">find / -size +100M -exec ls -lh &#123;&#125; \; 查询大于100M的文件</span><br><span class="line">free -m  查看内存剩余大小</span><br><span class="line"></span><br><span class="line">六、查看jvm大小</span><br><span class="line">ps -ef | grep  java</span><br><span class="line"></span><br><span class="line">七、权限（用户权限和读写执行权限）</span><br><span class="line">chmod 777 给文件赋予所有权限</span><br><span class="line">chmod +x 给文件赋予可执行权限</span><br><span class="line">chmod 755 -rwxr-xr-x</span><br><span class="line">chmod 744 -rwxr--r--</span><br><span class="line">su - deployer 切换到deployer用户</span><br><span class="line">su -i 切换到root</span><br><span class="line">sudo 可执行root权限操作</span><br><span class="line">sudo chown aiuap_jc:aiuap_jc iss  把iss目录的root拥有权限改成aiuap_jc</span><br><span class="line"></span><br><span class="line">八、用户和群组</span><br><span class="line">useradd -c Name Surname  -g admin -d homeuser1 -s binbash user1 创建一个属于 admin 用户组的用户</span><br><span class="line">useradd user1 创建一个新用户</span><br><span class="line">userdel -r user1 删除一个用户 ( '-r' 排除主目录)</span><br><span class="line">usermod -c User FTP -g system -d ftpuser1 -s binnologin user1 修改用户属性</span><br><span class="line">passwd 修改口令</span><br><span class="line">passwd user1 修改一个用户的口令 (只允许root执行)</span><br><span class="line">userdel peter 删除用户</span><br><span class="line">useradd -d /var/ftp -s /sbin/nologin 12321</span><br><span class="line">groupadd group_name 创建一个新用户组</span><br><span class="line">groupdel group_name 删除一个用户组</span><br><span class="line">groupmod -n new_group_name old_group_name 重命名一个用户组</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">Nginx配置</span><br><span class="line">cd /usr/local/nginx/</span><br><span class="line">cd /opt/issystem/logs/nginx/</span><br><span class="line">sudo tail -f -n 1000 access.log</span><br><span class="line">sudo ./nginx -s reload</span><br><span class="line">/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf</span><br><span class="line"></span><br><span class="line">Mysql导入导出：</span><br><span class="line">导出（无需登录）:</span><br><span class="line">mysqldump -uroot -punisk.88 isdb &gt; isdb-20171124.sql</span><br><span class="line">mysqldump -uroot -punisk.88 isdb tb_d_uniskuser &gt; tb_d_uniskuser.sql</span><br><span class="line">mysqldump -t isdb -uroot -punisk.88 --tables tb_d_rubbish tb_d_rubbish_appeal &gt; rubbishAll.sql</span><br><span class="line">zip -r isdb-20170828.zip isdb-20170828.sql</span><br><span class="line"></span><br><span class="line">导入（需要登录）：</span><br><span class="line">./mysqllogin</span><br><span class="line">use isdb;</span><br><span class="line">source /root/isdb-20171124.sql;</span><br><span class="line"></span><br><span class="line">查找文件或者文件夹</span><br><span class="line">find / -name filename.txt 根据名称查找/目录下的filename.txt文件</span><br><span class="line">find . -name "*.xml" 递归查找所有的xml文件</span><br><span class="line">find . -name "*.xml" |xargs grep "hello world" 递归查找所有文件内容中包含hello world的xml文件</span><br><span class="line">grep -H 'spring' *.xml 查找所有的包含spring的xml文件</span><br><span class="line">find ./ -size e | xargs rm -f &amp; 删除文件大小为零的文件</span><br><span class="line">ls -l | grep '.jar' 查找当前目录中的所有jar文件</span><br><span class="line">grep 'test' d* 显示所有以d开头的文件中包含test的行</span><br><span class="line">grep 'test' aa bb cc 显示在aa,bb,cc文件中匹配test的行</span><br><span class="line">grep '[a-z]\&#123;$\&#125;' aa 显示所有包含每个字符串至少有5个连续小写字符的字符串的行。</span><br><span class="line"></span><br><span class="line">查找后台运行的程序 以tomcat为例</span><br><span class="line">ps -ef|grep tomcat 查看所有tomcat的进程</span><br><span class="line">ps -ef|grep --color java 高亮要查询的关键字</span><br><span class="line">查看端口占用情况</span><br><span class="line">netstat -tln | grep 8080 查看端口8080的使用情况</span><br><span class="line"></span><br><span class="line">查看端口属于哪个程序</span><br><span class="line">lsof -i :8080</span><br><span class="line"></span><br><span class="line">查看后台进程</span><br><span class="line">ps aux|grep java 查看java进程</span><br><span class="line">ps aux 查看所有进程</span><br><span class="line"></span><br><span class="line">以树状图列出目录的内容</span><br><span class="line">tree a</span><br><span class="line"></span><br><span class="line">文件下载</span><br><span class="line">wget http://file.tgz</span><br><span class="line">curl http://file.tgz</span><br><span class="line"></span><br><span class="line">远程登录</span><br><span class="line">ssh username@ip</span><br><span class="line"></span><br><span class="line">打印信息</span><br><span class="line">echo $JAVA_HOME 打印java home环境变量的值</span><br></pre></td></tr></table></figure>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><span class="line">一、系统信息</span><br><span class="line">uname -a   查看内核/操作系统/CPU信息的linux系统信息命令</span><br><span class="line">lsb_release -a 查看操作系统  注：可惜需要安装 yum -y -install lsb</span><br><span class="line">head -n 1 /etc/issue   查看操作系统版本，是数字1不是字母L</span><br><span class="line">cat /proc/cpuinfo # 查看CPU信息的linux系统信息命令</span><br><span class="line">cat /proc/cpuinfo |grep "model name" &amp;&amp; cat /proc/cpuinfo |grep "physical id"   查看linux CPU大小</span><br><span class="line">cat /proc/meminfo |grep MemTotal   查看内存大小</span><br><span class="line">grep MemFree /proc/meminfo # 查看空闲内存量</span><br><span class="line">cat /proc/partitions ：查看linux硬盘和分区信息的系统信息命令</span><br><span class="line">cat /proc/meminfo ：查看linux系统内存信息的linux系统命令</span><br><span class="line">cat /proc/version ：查看版本，类似uname -r</span><br><span class="line">cat /proc/ioports ：查看设备io端口</span><br><span class="line">cat /proc/interrupts ：查看中断</span><br><span class="line">cat /proc/pci ：查看pci设备的信息</span><br><span class="line">cat /proc/swaps ：查看所有swap分区的信息</span><br><span class="line">ifconfig -a  查看IP地址</span><br><span class="line">lsblk 查看所有硬盘</span><br><span class="line">fdisk -l |grep Disk   查看硬盘大小</span><br><span class="line">hostname 查看计算机名的linux系统信息命令</span><br><span class="line">lspci -tv  列出所有PCI设备</span><br><span class="line">lsusb -tv 列出所有USB设备的linux系统信息命令</span><br><span class="line">lsmod  列出加载的内核模块</span><br><span class="line">env  查看环境变量资源</span><br><span class="line">free -m  查看内存使用量和交换区使用量</span><br><span class="line">df -h  查看各分区使用情况</span><br><span class="line">du -sh  查看指定目录的大小</span><br><span class="line">uptime  查看系统运行时间、用户数、负载</span><br><span class="line">cat /proc/loadavg  查看系统负载磁盘和分区</span><br><span class="line">mount | column -t  查看挂接的分区状态</span><br><span class="line">fdisk -l  查看所有分区</span><br><span class="line">swapon -s  查看所有交换分区</span><br><span class="line">hdparm -i /dev/hda  查看磁盘参数(仅适用于IDE设备)</span><br><span class="line">dmesg | grep IDE  查看启动时IDE设备检测状况网络</span><br><span class="line">ifconfig 查看所有网络接口的属性</span><br><span class="line">iptables -L  查看防火墙设置</span><br><span class="line">route -n 查看路由表</span><br><span class="line">netstat -lntp  查看所有监听端口</span><br><span class="line">netstat -antp  查看所有已经建立的连接</span><br><span class="line">netstat -s  查看网络统计信息进程</span><br><span class="line">ps -ef 查看所有进程</span><br><span class="line">top  实时显示进程状态用户</span><br><span class="line">w  查看活动用户</span><br><span class="line">id  查看指定用户信息</span><br><span class="line">last  查看用户登录日志</span><br><span class="line">cut -d: -f1 /etc/passwd  查看系统所有用户</span><br><span class="line">cut -d: -f1 /etc/group # 查看系统所有组</span><br><span class="line">crontab -l  查看当前用户的计划任务服务</span><br><span class="line">chkconfig –list 列出所有系统服务</span><br><span class="line">chkconfig –list | grep on  列出所有启动的系统服务程序</span><br><span class="line"></span><br><span class="line">二、软件信息</span><br><span class="line">./version.sh  查看tomcat jvm版本 先进到tomcat的bin目录</span><br><span class="line">cd /usr/local/nginx/sbin  ./nginx -v     查看nginx 版本</span><br><span class="line">mysql -v    查看mysql 版本</span><br><span class="line">java -version  查看java版本</span><br><span class="line">whereis java</span><br><span class="line">which java （java执行路径）</span><br><span class="line">echo $JAVA_HOME</span><br><span class="line">echo $PATH</span><br><span class="line"></span><br><span class="line">三、网络</span><br><span class="line">service network restart 重启网络</span><br><span class="line">netstat -anp|grep 80 网络管理netstat命令 查看端口</span><br><span class="line"></span><br><span class="line">四、关机 (系统的关机、重启以及登出 )</span><br><span class="line">shutdown -h now 关闭系统(1)</span><br><span class="line">init 0 关闭系统(2)</span><br><span class="line">telinit 0 关闭系统(3)</span><br><span class="line">shutdown -h hoursminutes &amp; 按预定时间关闭系统</span><br><span class="line">shutdown -c 取消按预定时间关闭系统</span><br><span class="line">shutdown -r now 重启(1)</span><br><span class="line">reboot 重启(2)</span><br><span class="line">logout 注销</span><br><span class="line"></span><br><span class="line">五、挂载文件</span><br><span class="line">mount devhda2 mnthda2 挂载一个叫做hda2的盘 - 确定目录 ' mnthda2' 已经存在</span><br><span class="line">umount devhda2 卸载一个叫做hda2的盘 - 先从挂载点 ' mnthda2' 退出</span><br><span class="line">fuser -km mnthda2 当设备繁忙时强制卸载</span><br><span class="line">umount -n mnthda2 运行卸载操作而不写入 etcmtab 文件- 当文件为只读或当磁盘写满时非常有用</span><br><span class="line">mount devfd0 mntfloppy 挂载一个软盘</span><br><span class="line">mount devcdrom mntcdrom 挂载一个cdrom或dvdrom</span><br><span class="line">mount devhdc mntcdrecorder 挂载一个cdrw或dvdrom</span><br><span class="line">mount devhdb mntcdrecorder 挂载一个cdrw或dvdrom</span><br><span class="line">mount -o loop file.iso mntcdrom 挂载一个文件或ISO镜像文件</span><br><span class="line">mount -t vfat devhda5 mnthda5 挂载一个Windows FAT32文件系统</span><br><span class="line">mount devsda1 mntusbdisk 挂载一个usb 捷盘或闪存设备</span><br><span class="line">mount -t smbfs -o username=user,password=pass WinClientshare mntshare 挂载一个windows网络共享</span><br><span class="line"></span><br><span class="line">六、磁盘空间</span><br><span class="line">df -h 显示已经挂载的分区列表</span><br><span class="line">ls -lSr more 以尺寸大小排列文件和目录</span><br><span class="line">du -sh dir1 估算目录 'dir1' 已经使用的磁盘空间'</span><br><span class="line">du -sk   sort -rn 以容量大小为依据依次显示文件和目录的大小</span><br><span class="line">rpm -q -a --qf '%10&#123;SIZE&#125;t%&#123;NAME&#125;n'  sort -k1,1n 以大小为依据依次显示已安装的rpm包所使用的空间</span><br></pre></td></tr></table></figure>
</section>
    <!-- Tags START -->
    
    <div class="tags">
      <span>Tags:</span>
      
  <a href="/tags#Linux">
    <span class="tag-code">Linux</span>
  </a>

    </div>
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/2019/05/24/Linux/linuxmysql常用脚本/">
        <span class="nav-arrow">← </span>
        
          linux mysql 常用脚本
        
      </a>
    
    
      <a class="nav-right" href="/2019/05/24/Linux/Mysqldata存储路径修改/">
        
          Mysql data 存储路径修改
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
    <div class="money-like">
      <div class="reward-btn">
        赏
        <span class="money-code">
          <span class="alipay-code">
            <div class="code-image"></div>
            <b>使用支付宝打赏</b>
          </span>
          <span class="wechat-code">
            <div class="code-image"></div>
            <b>使用微信打赏</b>
          </span>
        </span>
      </div>
      <p class="notice">若你觉得我的文章对你有帮助，欢迎点击上方按钮对我打赏</p>
    </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
    <div class="qrcode">
      <canvas id="share-qrcode"></canvas>
      <p class="notice">扫描二维码，分享此文章</p>
    </div>
    
    <!-- 二维码 END -->
    
    <!-- No Comment -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
  <aside class="catalog-container">
  <div class="toc-main">
    <strong class="toc-title">Catalog</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-1"><a class="toc-nav-link" href="#Linux-system-命令"><span class="toc-nav-text">Linux system 命令</span></a></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'https://fengzhaoy.github.io/2019/05/24/Linux/Linuxsystem命令/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function () {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function () {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="' + src +
          '" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function () {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


<script>
  var qr = new QRious({
    element: document.getElementById('share-qrcode'),
    value: document.location.href
  });
</script>





    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
  <p class="copyright">
    &copy; 2019
  </p>
</footer>

<script>
  function async (u, c) {
    var d = document,
      t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) {
      o.addEventListener('load', function (e) {
        c(null, e);
      }, false);
    }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async ("//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", function () {
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async ("//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function () {
    $('figure pre').each(function (i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>
<!-- Baidu Tongji -->

<script src="/js/script.js"></script>
  </body>
</html>